<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <link rel="stylesheet" href="../css/myequipment.css">
    <link rel="stylesheet" href="../css/ubddevice.css">
    <script src="../js/jquery.min.js"></script>
    <script src="../js/fontzize.js"></script>
    <script src="../js/vue.min.js"></script>
    <script src="../js/jsonAjax.js"></script>
</head>
<body>
<div id="app">
    <aside :class="{animation:asidebule}">
        <ul>
            <h3>设备选择</h3>
           <li v-for="(item,index) in jsondevicelist" v-html="item.patient_name" @click="gocids(item)"></li>
        </ul>
    </aside>
    <div class="pr" :class="{'transition':transition}" id="pages">
        <article>
            <p class="title">剩余格子数</p>
            <!---->
            <div class="lattice" @click="kitDetails" v-html="datalists.ceil_remaining"></div>
            <div class="prompt" v-if="datalists.error_info!=''">
                <img src="../imgs/exclamation_1.png" @click="erinfoShow=true"/>
            </div>
            <div class="promptmsg">
                <img src="../imgs/drug.png">正准备服用
            </div>
            <div class="ptcontent">
                <div v-html="datalists.next_time"></div>
                <div v-html="datalists.next_drug_name"></div>
                <div v-html="datalists.remark"></div>
            </div>
        </article>
        <section>
            <div class="porelative">
                <div class="iconlink">
                    <div><img src="../imgs/smile.png"><span>按时</span></div>
                    <div><img src="../imgs/smile-2.png" ><span>超时</span></div>
                    <div><img src="../imgs/smile-3.png"><span>漏用</span></div>
                </div>
                <div class="hiscontent">
                    <dl v-for="item in datalists.alarmclock">
                        <dt v-if="item.status==0"></span></dt>
                        <dt v-if="item.status==1"><span style="background: #00cc33"></span></dt>
                        <dt v-if="item.status==2||item.status==3"><span style="background: #ffd543"></span></dt>
                        <dt v-if="item.status==4"><span style="background: #ff9567"></span></dt>
                        <dd v-html="item.alarm_time"></dd>
                        <dd v-html="item.drugsname"></dd>
                        <dd v-html="item.remark"></dd>
                    </dl>

                </div>
            </div>
        </section>
        <div class="error_info" v-if="erinfoShow" @click="erinfoShow=false">
            <div class="iffor">
                <div class="tits">设备状态异常</div>
                <div class="error" v-html="error_info"></div>
            </div>
        </div>
    </div>
    <footer>
        <nav @click="aside">三</nav>
        <nav @click="jilu">记录</nav>
        <nav @click="tixing">提醒</nav>
        <nav >设备</nav>
    </footer>
    <div class="lodingboc" v-show="lodingboc">
        <img src="../imgs/loding.gif" alt="">
    </div>
</div>
<script type="text/javascript">
    Vue.config.debug = true;
    app = new Vue({
        el: "#app",
        data: {
            device_id: 0,
            jsondevicelist: [],//智能硬件ID号列表
            defaindex: 0,
            datalists: [],
            bgcolor: [],
            erinfoShow: false,
            error_info:'',
            asidebule:false,
            transition:false,
            lodingboc:true
        },
        mounted: function () {
            var _this = this;
            //获取外部链接参数
            function GetQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null)return unescape(r[2]);
                return null;
            }

            var myurl = GetQueryString("details");
            if (myurl != null && myurl.toString().length > 1) {
                _this.device_id = Number(GetQueryString("details").substr(1));

            }
            else {
                //window.location.href =golinks("");
            }
            var role = GetQueryString("role");
            if (role != null && myurl.toString().length > 1) {
                _this.role = Number(GetQueryString("role").substr(1));

            }
            else {
                //window.location.href =golinks("");
            }

           setTimeout(function () {
                getStages('user');
            },90);
            setTimeout(function () {
                if(!BooleanStages){
                    window.location.href = golinks("");
                }else {
                    _this.token = StagesDatas.usermsg.access_token;
                    _this.uid = StagesDatas.usermsg.uid;
                    //接口名称 11 根据用户ID获取设备列表√
                    jsonAjax('/Home/Device/get_device_list_by_uid',
                        {access_token:_this.token, uid:_this.uid}
                    ).done(function (data) {
                        if(data.code==40002){
                            window.location.href=golinks('weixinsq.html')
                        }
                        if(data.code==40010){
                            window.location.href=golinks('weixinsq.html')
                        }
                        else if(data.code ==0){

                            if(data.data.length<=0){
                                window.location.href=golinks("associateddevice/wifinetwork.html");
                            }else {
                                if(!_this.device_id){
                                    _this.device_id=data.data[0].device_id;
                                    _this.getcoi(data.data[0].device_id)
                                    _this.role=data.data[0].role;

                                }else {
                                    _this.getcoi(_this.device_id);
                                }
                                _this.jsondevicelist=data.data;

                            }
                        }
                    })
                        .fail(function () {
                            console.log("error");
                        });
                }

            },320);
        },
        methods: {
            getcoi:function (device_id) {
                var _this = this;
                setTimeout(function () {
                    _this.token = StagesDatas.usermsg.access_token;
                    _this.uid = StagesDatas.usermsg.uid;
                    //18 获取当前设备的服药信息√
                    jsonAjax("/Home/device/get_device_current_info_new",
                        {access_token: _this.token, device_id: device_id, uid: _this.uid}
                    ).done(function (data) {
                        if(data.code==40002){
                            window.location.href=golinks('weixinsq.html')
                        }
                        if(data.code==40010){
                            window.location.href=golinks('weixinsq.html')
                        }
                        else if(data.code ==0){
                            _this.datalists = data.data;
                            _this.error_info=data.data.error_info

                        }
                        _this.lodingboc=false;

                    })
                        .fail(function () {
                            console.log("error");
                        });
                },100);
            },
            aside:function () {
                console.log("s")
                this.transition =!this.transition;
            },
            jilu:function () {
                window.location.href = golinks("endar.html?details="+this.device_id+"&role="+this.role+"");
            },
            tixing:function () {
                window.location.href = golinks("medicationplan.html?devicid="+this.device_id+"&role="+this.role+"");
            },
            gocids:function (e) {
                this.transition =!this.transition;
                this.bcid=e.cid;
                this.role=e.role;
                this.device_id=e.device_id;
                this.getcoi(e.device_id)
            },
            gotolink: function () {
                location.href = golinks("dmanagement/devicedetails.html?device_id=" + this.device_id + "")
            },
            kitDetails: function () {
                console.log(this.device_id)
                location.href = golinks("kitContents/kitDetails.html?device_id=" + this.device_id + "");
            },
            medicationPlan: function () {
                //
                var lisdata = JSON.parse(localStorage.getItem('device_ids'));
                var lisarry = [];
                for (var i = 0; i < lisdata.length; i++) {
                    lisarry.push(Number(lisdata[i].device_id));
                }
                var index = lisarry.indexOf(this.device_id);
                location.href = golinks("medicationplan.html?devicid=" + index + "");
            },

        }

    });
    eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('4.6("7").8(\'b\',2,3);4.6("7").8(\'c\',2,3);4.6("7").8(\'a\',2,3);e 2(1){m 1=1||n.1;l(1.j){5"b":9;5"a":9;5"c":k(1.h[0].f<d){i.g=3}9}}',24,24,'|event|touch|false|document|case|getElementById|pages|addEventListener|break|touchend|touchstart|touchmove|250|function|clientX|transition|touches|app|type|if|switch|var|window'.split('|'),0,{}))
</script>
</body>

</html>

